# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.proto.coin_executor_pb2 import PassiveExecutorConfig
from coin.proto.coin_request_pb2 import StrategyRequestProto
from coin.strategy.mm.subscription import SubscriptionRequest
from coin.experimental.jaewon.strat.pass_model import PassModelConfig
from coin.experimental.jaewon.strat.pass_model_strategy import PassModelStrategyConfig
from coin.exchange.huobi_futures.kr_rest.futures_product import HuobiFuturesProduct


def second(x):
  return int(x * 10**9)


def strategy_config():
  symbol_str = 'BTC-USD.THIS_WEEK'

  strategy_config = PassModelStrategyConfig(
      trade_product=HuobiFuturesProduct.FromStr(symbol_str),
      trade_sub_req=SubscriptionRequest('Futures', 'Huobi'),
      executor_params=PassiveExecutorConfig(
          symbol=symbol_str,
          lot_size=50.,
          min_pos=-250.,
          max_pos=+250.,
          order_update_period=second(2.),
          min_posting_period=second(0.2),
          max_posting_period=second(2.),
          fill_cooldown_period=second(0.01),
          post_only=False,
      ),
      model_config=PassModelConfig(
          symbol_nick='huobi-btcusd-this_week',
          linear_model_filepath='~/deploy/models/model_huobi-btcusd-this_week.pkl.gz',
          bound_price=False,
          sampler_offsets={
              'sampler/low_vol': 5.,
              'sampler/mid_vol': 5.,
              'sampler/high_vol': 5.,
          },
          lt_model_param={'version': 2},
          ref_symbol_nicks=['bitflyer-fxbtcjpy'],
      ),
      init_og_after_min=20,
      exit_after_min=30,
      og_params={
          'Futures.Huobi': {
              'rest_disable_ssl': True,
              'rest_root_url': 'xiguaapi.hbdm.com',
          },
      },
      strategy_request=StrategyRequestProto(
          strategy_name='pass_model_huobi_btcusd_this_week',
          strategy_group='pass_model',
          trader='jaewon',
      ))
  return strategy_config


if __name__ == '__main__':
  print(strategy_config())
